<!DOCTYPE html>
<!--
This is a starter template page. Use this page to start your new project from
scratch. This page gets rid of all links and provides the needed markup only.
-->
<html lang="en">

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta http-equiv="x-ua-compatible" content="ie=edge">

  <title><%=SETTING.website_name%></title>

  <%- include(VIEWROOT+'common/cssjs.html'); %>
  <style>
      ._selected{
        text-decoration:underline;
        color:#33C;
        font-weight:bold;
        font-size:14px;	
      }
      </style>
</head>

<body class="hold-transition sidebar-mini">
  <div class="wrapper">

    <%- include(VIEWROOT+'common/navbar.html'); %>

    <%- include(VIEWROOT+'common/sidebar.html'); %>



    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">

      <!-- Main content -->
      <div class="content">
          <div class="container-fluid">
              <div class="row">
                <!-- /.col-md-12 -->
                <div class="col-lg-12">
                  <div class="card card-primary">
                    <div class="card-header">
                      <h3 class="card-title">权限管理</h3>
                    </div>
                    <!-- /.card-header -->
                    <form action="" method="post" id="myform">
                        <input type="hidden" name="moduleid" value="<%=moduleid%>">
                        <input type="hidden" name="module" value="<%=mod['module_en']%>">
                        <table class="table table-bordered" width="100%">
                          <tr>
                            <td align="center">
                        
                            <% 
                            for(let k in module_list){ 
                              let v=module_list[k];
                              if(!v['is_auth']) continue;
                            %>
                            <a href="/member/authenticate?moduleid=<%=v.moduleid%>&userid=<%=userid%>" <% if(moduleid==v['moduleid']){ %> class="_selected" <% } %>><%=v['moduleid']%> <%=v['module_cn']%>[<%=v['module_en']%>]</a>&nbsp;
                            <% } %>
                            </td>
                        
                          </tr>
                          
                          <tr>
                            <td align="center">
                            <div style="margin:0 auto;width:400px;text-align:left;">
                            <h3><span style="cursor:pointer;" onClick="javascript:$('input[name=\'access\']').prop('checked', true);">全选</span>/<span style="cursor:pointer;" onClick="javascript:$('input[name=\'access\']').prop('checked', false);">取消</span></h3>
                            <ol>
                            <%
                            let md=CORE_CONF.mod_auth(moduleid);
                            if(!functions.in_object(mod['module_en'],checked)) checked[mod['module_en']]=[];
                            for(let kk in md){
                              let vv=md[kk];
                              if(!vv['is_auth']) continue;
                            %>
                            <li><label><input class="big_checkbox"  <% if(functions.in_array(vv['name'],checked[mod['module_en']])){ %> checked="checked" <% } %> type="checkbox" name="access" value="<%=vv['name']%>"> <%=vv['chinese']%>[<%=vv['name']%>]</label></li>
                            <% } %>
                            </ol>
                            
                            </div>
                            </td>
                          </tr>
                          
                          
                        <tr>
                            <td colspan="2" align="center"><input type="submit" value="提交" class="btn btn-success"></td>
                        </tr>
                        </table>
                        </form>        
                  </div>
                </div>
    
    
    
                <!-- /.col-md-12 -->
              </div>
              <!-- /.row -->
            </div><!-- /.container-fluid -->
      </div>
      <!-- /.content -->
    </div>
    <!-- /.content-wrapper -->

    <!-- Control Sidebar -->
    <aside class="control-sidebar control-sidebar-dark">
      <!-- Control sidebar content goes here -->
      <div class="p-3">
        <h5>Title</h5>
        <p>Sidebar content</p>
      </div>
    </aside>
    <!-- /.control-sidebar -->


    <%- include(VIEWROOT+'common/footer.html'); %>
  </div>
  
</body>

</html>